package com.work.vo.main;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.work.constant.DictBizConstant;
import com.work.constant.TallyType;
import com.work.utils.BigDecimalSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.DictBizCache;

import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * 散货外捣检算VO
 *
 * @author ：dujianyu
 * @since ：Created in 2024/6/12 10:26
 */
@Data
public class BulkTallyCheckVO {


    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long oriTransportShipId;

    @ApiModelProperty(value = "理货日期")
    private LocalDate tallyDate;

    @ApiModelProperty(value = "时间段")
    private String timeSpace;

    @ApiModelProperty(value = "时间段")
    private String timeSpaceName;

    public String getTimeSpaceName() {
        if (Func.isNull(timeSpace)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TIME_SPACE, timeSpace);
    }

    @ApiModelProperty(value = "时间信息")
    private String timeInfo;

    public String getTimeInfo() {
        if (Func.isNull(timeSpace) || Func.isNull(tallyDate)) {
            return "";
        }
        return tallyDate + "/" + DictBizCache.getValue(DictBizConstant.TIME_SPACE, timeSpace);
    }

    @ApiModelProperty(value = "船名")
    private String shipNameZh;

    @ApiModelProperty(value = "理货货名")
    private String cargoType;

    @ApiModelProperty(value = "理货货名")
    private String cargoTypeName;

    @ApiModelProperty(value = "作业过程")
    private String operationType;

    @ApiModelProperty(value = "作业过程")
    private String operationTypeName;

    @ApiModelProperty(value = "作业活动")
    private String workActivity;

    @ApiModelProperty(value = "作业活动")
    private String workActivityName;

    @ApiModelProperty(value = "理货类型")
    private String tallyType;

    @ApiModelProperty(value = "理货类型")
    private String tallyTypeName;

    public String getTallyTypeName() {
        if (Func.isNull(tallyType)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TALLY_TYPE, tallyType);
    }

    @ApiModelProperty(value = "航陆运")
    private String shipLand;

    @ApiModelProperty(value = "航陆运")
    private String shipLandName;

    public String getShipLandName() {
        if (Func.isNull(shipLand)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.SHIP_LAND, shipLand);
    }

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "理货吨数")
    private BigDecimal oriTon;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "货场")
    private Long oriPositionId;

    @ApiModelProperty(value = "货场")
    private String oriPositionName;

    @ApiModelProperty(value = "货位")
    private String oriSpot;

    @ApiModelProperty(value = "货位")
    private String oriPositionInfo;

    public String getOriPositionInfo() {
        if (Func.isNull(oriPositionName) || Func.isNull(oriSpot)) {
            return "";
        }
        return oriPositionName + "/" + oriSpot;
    }

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "理货吨数")
    private BigDecimal toTon;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "货场")
    private Long toPositionId;

    @ApiModelProperty(value = "货场")
    private String toPositionName;

    @ApiModelProperty(value = "货位")
    private String toSpot;

    @ApiModelProperty(value = "货位")
    private String toPositionInfo;

    public String getToPositionInfo() {
        if (Func.isNull(toPositionName) || Func.isNull(toSpot)) {
            return "";
        }
        return toPositionName + "/" + toSpot;
    }

    @ApiModelProperty(value = "件信息")
    private String pieceInfo;

    @ApiModelProperty(value = "吨信息")
    private String tonInfo;

    public String getTonInfo() {
        if (Func.isNull(oriTon)) {
            return "";
        }
        if (TallyType.VARIOUS.equals(tallyType)) {
            return oriTon.stripTrailingZeros().toPlainString() + "->" + toTon.stripTrailingZeros().toPlainString();
        }

        return oriTon.stripTrailingZeros().toPlainString();

    }


    @ApiModelProperty(value = "区域信息")
    private String positionInfo;

    public String getPositionInfo() {
        if (Func.isNull(oriPositionId)) {
            return "";
        }
        if (TallyType.VARIOUS.equals(tallyType)) {
            return oriPositionName + "/" + oriSpot + "->" + toPositionName + "/" + toSpot;
        }

        return oriPositionName + "/" + oriSpot;

    }

    @ApiModelProperty(value = "是否审核")
    private String isCheck;

    @ApiModelProperty(value = "检算类型")
    private String checkType;

    @ApiModelProperty(value = "检算类型")
    private String checkTypeName;

    public String getCheckTypeName() {
        if (Func.isNull(checkType)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.CHECK_TYPE, checkType);
    }

    @ApiModelProperty(value = "检算类型")
    private String checkReason;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "检算吨数")
    private BigDecimal checkOriTon;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "检算吨数")
    private BigDecimal checkToTon;

    @ApiModelProperty(value = "理货员")
    private String createUserName;

    @ApiModelProperty(value = "装卸队")
    private String workerInfo;

    @ApiModelProperty(value = "安全生产")
    private String isSafeProduction;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "区域ID")
    private Long areaId;

    @ApiModelProperty(value = "机械")
    private String machineInfo;


}
